import Mock from 'mockjs';

const { data } = Mock.mock({
    'data|4': [
        {
            'img': 'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/u159.svg',

        }
    ]
})


const { picture } = Mock.mock({
    'picture|20': [
        {
            'img|1': [
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p0.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p7.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p2.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p11.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p4.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p13.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p9.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5/p32.png'
            ],
            id: 'picture-' + '@guid',
            proname: '@ctitle(5, 10)',
            name: '@first',
            'img2|1': [
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p1.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p8.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p3.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p12.png',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E9%A6%96%E9%A1%B5_%E6%9C%AA%E7%99%BB%E5%BD%95/p5.png',
            ]

        }
    ]
})


const { tourism } = Mock.mock({
    'tourism|10': [
        {
            id: 'tourism-' + '@guid',
            'img|1': [
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E4%B8%BB%E9%A2%98%E6%99%AF%E7%82%B9%E5%88%97%E8%A1%A8/u538.svg',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E4%B8%BB%E9%A2%98%E6%99%AF%E7%82%B9%E5%88%97%E8%A1%A8/u538-0.svg',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E4%B8%BB%E9%A2%98%E6%99%AF%E7%82%B9%E5%88%97%E8%A1%A8/u538-1.svg',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E4%B8%BB%E9%A2%98%E6%99%AF%E7%82%B9%E5%88%97%E8%A1%A8/u538-2.svg',
                'https://cdn7.axureshop.com/demo2024/2251242/images/%E4%B8%BB%E9%A2%98%E6%99%AF%E7%82%B9%E5%88%97%E8%A1%A8/u538-3.svg'
            ],
            'proname|1': [
                '故宫博物馆', '八达岭长城', '香山公园', '白塔寺', '湖广会馆'
            ],
            'type|1': ['亲子游', '文化游', '温泉游', '周边游'],
            'content|1': '@cparagraph(1, 3)',
            'number|1000-9000': 1006,
            'address|1': ['1.2km', '2.3km', '3.4km', '4.5km', '5.6km'],
        }
    ]
})


const { history } = Mock.mock({
    'history|3': [
        {
            'proname|1': ['故宫博物馆', '八达岭长城', '香山公园'],
        }
    ]
})

Mock.mock('/api/getSwipeData', 'post', () => {

    return {
        code: 200,
        message: '获取数据成功',
        data: {
            data
        }
    }
})



Mock.mock('/api/getPicture', 'post', () => {

    return {
        code: 200,
        message: '获取数据成功',
        data: {
            data: picture
        }
    }
})


Mock.mock('/api/getTourism', 'post', () => {

    return {
        code: 200,
        message: '获取数据成功',
        data: {
            data: tourism
        }
    }
})


Mock.mock('/api/searchTourism', 'post', (config) => {
    const { proname } = JSON.parse(config.body)

    //@ts-ignore
    const result = tourism.filter(item => item.proname.includes(proname))

    if (result.length === 0) {

        return {
            code: 400,
            message: '没有找到相关数据',
        }

    }
    return {
        code: 200,
        message: '查询成功',
        data: {
            data: result
        }
    }
})

Mock.mock('/api/getHistory', 'post', () => {
    return {
        code: 200,
        message: '获取数据成功',
        data: {
            data: history
        }
    }
})

Mock.mock('/api/addHistory', 'post', (config) => {
    const { proname } = JSON.parse(config.body)

    history.unshift({
        proname
    })

    return {
        code: 200,
        message: '添加成功',
        data: {
            data: history
        }
    }
})